from python_ai.common.xcommon import sep
import warnings
import numpy as np
import matplotlib.pyplot as plt
import tensorflow.compat.v1 as tf

warnings.simplefilter('error', UserWarning)

input = tf.placeholder(tf.float32, [100, 7, 7, 3], 'input')

# ATTENTION
# input: `"NHWC" or "NCHW"`
# filter: A 4-D tensor of shape
#       `[filter_height, filter_width, in_channels, out_channels]`
# padding:
#       VALID: No padding
#           20x20=strides1x1=>18x18
#           20x20=strides2x2=>9x9
#           7x7=strides1x1=>5x5
#           7x7=strides2x2=>3x3
#       SAME: Padding to the same size of input
#           20x20=strides1x1=>20x20
#           20x20=strides2x2=>10x10
#           7x7=strides1x1=>7x7
#           7x7=strides2x2=>4x4
# strides: An int or list of `ints` that has length `1`, `2` or `4`.  The
#       stride of the sliding window for each dimension of `input`. If a single
#       value is given it is replicated in the `H` and `W` dimension. By default
#       the `N` and `C` dimensions are set to 1. The dimension order is determined
#       by the value of `data_format`, see below for details.
# Returns:
#     A `Tensor`. Has the same type as `input`.
result_1_valid = tf.nn.conv2d(input, tf.random.normal([3, 3, 3, 1]), strides=1, padding='VALID', name='1_valid')
print(result_1_valid)
result_1_same = tf.nn.conv2d(input, tf.random.normal([3, 3, 3, 2]), strides=1, padding='SAME', name='1_same')
print(result_1_same)
result_2_valid = tf.nn.conv2d(input, tf.random.normal([3, 3, 3, 2]), strides=2, padding='VALID', name='2_valid')
print(result_2_valid)
result_2_same = tf.nn.conv2d(input, tf.random.normal([3, 3, 3, 2]), strides=2, padding='SAME', name='2_same')
print(result_2_same)
